$(function() {
    console.log('Loading')
    let elem = $('#limit');
    
    chrome.storage.sync.get('limit',function({limit}){
        $('#limit').val(limit)
    })
    //设置上限
    $("#setlimit").click(function(){
        // let elem = $('#setlimit');
        let limit = elem.val();
        if(limit){
            chrome.storage.sync.set({'limit': limit})
        }
    })
    //清除总金额
    $('#resettotal').click(function(){
        // console.log('Loading')
        chrome.storage.sync.set({'total':0},function(){
            var options={
                type:'basic',
                iconUrl:'img/logo.png',
                title:'消费金额清零',
                message:'您的消费金额已清零'
            }
            chrome.notifications.create("resettotal",options)
        })
    })
})